<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/file/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/file/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/file/favicon-16x16.png">
  <link rel="mask-icon" href="/file/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"czlz.net","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="密码学第二天，仍然蒙蔽中。">
<meta property="og:type" content="article">
<meta property="og:title" content="密码学第二天（大比武_CTF课_第十四天）">
<meta property="og:url" content="https://czlz.net/2020/jxsw_dbw_crypto_2/index.html">
<meta property="og:site_name" content="粗制乱造的个人网站">
<meta property="og:description" content="密码学第二天，仍然蒙蔽中。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-07-15T16:00:00.000Z">
<meta property="article:modified_time" content="2020-07-25T07:45:45.482Z">
<meta property="article:author" content="粗制乱造">
<meta property="article:tag" content="CTF">
<meta property="article:tag" content="练习题">
<meta property="article:tag" content="密码学">
<meta property="article:tag" content="RSA">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://czlz.net/2020/jxsw_dbw_crypto_2/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>密码学第二天（大比武_CTF课_第十四天） | 粗制乱造的个人网站</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">粗制乱造的个人网站</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">杂七杂八的一堆东西</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-python">

    <a href="/pyodide/" rel="section"><i class="fa fa-user fa-fw"></i>在线Python3.8</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://czlz.net/2020/jxsw_dbw_crypto_2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/file/avatar.png">
      <meta itemprop="name" content="粗制乱造">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="粗制乱造的个人网站">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          密码学第二天（大比武_CTF课_第十四天）
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-07-16 00:00:00" itemprop="dateCreated datePublished" datetime="2020-07-16T00:00:00+08:00">2020-07-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-07-25 15:45:45" itemprop="dateModified" datetime="2020-07-25T15:45:45+08:00">2020-07-25</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/CTF/" itemprop="url" rel="index"><span itemprop="name">CTF</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/CTF/%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">笔记</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/CTF/%E7%AC%94%E8%AE%B0/crypto/" itemprop="url" rel="index"><span itemprop="name">crypto</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/CTF/%E7%AC%94%E8%AE%B0/crypto/%E4%BD%9C%E9%A2%98/" itemprop="url" rel="index"><span itemprop="name">作题</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <!-- toc -->
<pre><code>密码学第二天，仍然蒙蔽中。</code></pre><a id="more"></a>
<h1 id="0x01-can-you-get-the-equation"><a href="#0x01-can-you-get-the-equation" class="headerlink" title="0x01. can you get the equation"></a>0x01. can you get the equation</h1><h2 id="题目"><a href="#题目" class="headerlink" title="题目"></a>题目</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> gmpy2 <span class="keyword">import</span> lcm , powmod , invert , gcd , mpz</span><br><span class="line"><span class="keyword">from</span> Crypto.Util.number <span class="keyword">import</span> getPrime</span><br><span class="line"><span class="keyword">from</span> sympy <span class="keyword">import</span> nextprime</span><br><span class="line"><span class="keyword">from</span> random <span class="keyword">import</span> randint</span><br><span class="line">p = getPrime(<span class="number">1024</span>)</span><br><span class="line">q = getPrime(<span class="number">1024</span>)</span><br><span class="line">n = p * q</span><br><span class="line">gift = lcm(p - <span class="number">1</span> , q - <span class="number">1</span>)</span><br><span class="line">e = <span class="number">54722</span></span><br><span class="line">flag = <span class="string">b'NPUCTF&#123;******************&#125;'</span></span><br><span class="line">m = int.from_bytes(flag , <span class="string">'big'</span>)</span><br><span class="line">c = powmod(m , e , n)</span><br><span class="line">print(<span class="string">'n: '</span> , n)</span><br><span class="line">print(<span class="string">'gift: '</span> , gift)</span><br><span class="line">print(<span class="string">'c: '</span> , c)</span><br><span class="line"></span><br><span class="line"><span class="comment">#n:  17083941230213489700426636484487738282426471494607098847295335339638177583685457921198569105417734668692072727759139358207667248703952436680183153327606147421932365889983347282046439156176685765143620637107347870401946946501620531665573668068349080410807996582297505889946205052879002028936125315312256470583622913646319779125559691270916064588684997382451412747432722966919513413709987353038375477178385125453567111965259721484997156799355617642131569095810304077131053588483057244340742751804935494087687363416921314041547093118565767609667033859583125275322077617576783247853718516166743858265291135353895239981121</span></span><br><span class="line"><span class="comment">#gift:  2135492653776686212553329560560967285303308936825887355911916917454772197960682240149821138177216833586509090969892419775958406087994054585022894165950768427741545736247918410255804894522085720642952579638418483800243368312702566458196708508543635051350999572787188236243275631609875253617015664414032058822919469443284453403064076232765024248435543326597418851751586308514540124571309152787559712950209357825576896132278045112177910266019741013995106579484868768251084453338417115483515132869594712162052362083414163954681306259137057581036657441897428432575924018950961141822554251369262248368899977337886190114104</span></span><br><span class="line"><span class="comment">#c:  3738960639194737957667684143565005503596276451617922474669745529299929395507971435311181578387223323429323286927370576955078618335757508161263585164126047545413028829873269342924092339298957635079736446851837414357757312525158356579607212496060244403765822636515347192211817658170822313646743520831977673861869637519843133863288550058359429455052676323196728280408508614527953057214779165450356577820378810467527006377296194102671360302059901897977339728292345132827184227155061326328585640019916328847372295754472832318258636054663091475801235050657401857262960415898483713074139212596685365780269667500271108538319</span></span><br></pre></td></tr></table></figure>
<h2 id="解题原理"><a href="#解题原理" class="headerlink" title="解题原理"></a>解题原理</h2><h2 id="解题代码"><a href="#解题代码" class="headerlink" title="解题代码"></a>解题代码</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> gmpy2 <span class="keyword">import</span> invert,iroot,gcd</span><br><span class="line"><span class="keyword">from</span> Crypto.Util.number <span class="keyword">import</span> *</span><br><span class="line"></span><br><span class="line">n=<span class="number">17083941230213489700426636484487738282426471494607098847295335339638177583685457921198569105417734668692072727759139358207667248703952436680183153327606147421932365889983347282046439156176685765143620637107347870401946946501620531665573668068349080410807996582297505889946205052879002028936125315312256470583622913646319779125559691270916064588684997382451412747432722966919513413709987353038375477178385125453567111965259721484997156799355617642131569095810304077131053588483057244340742751804935494087687363416921314041547093118565767609667033859583125275322077617576783247853718516166743858265291135353895239981121</span></span><br><span class="line">gift=<span class="number">2135492653776686212553329560560967285303308936825887355911916917454772197960682240149821138177216833586509090969892419775958406087994054585022894165950768427741545736247918410255804894522085720642952579638418483800243368312702566458196708508543635051350999572787188236243275631609875253617015664414032058822919469443284453403064076232765024248435543326597418851751586308514540124571309152787559712950209357825576896132278045112177910266019741013995106579484868768251084453338417115483515132869594712162052362083414163954681306259137057581036657441897428432575924018950961141822554251369262248368899977337886190114104</span></span><br><span class="line">c=<span class="number">3738960639194737957667684143565005503596276451617922474669745529299929395507971435311181578387223323429323286927370576955078618335757508161263585164126047545413028829873269342924092339298957635079736446851837414357757312525158356579607212496060244403765822636515347192211817658170822313646743520831977673861869637519843133863288550058359429455052676323196728280408508614527953057214779165450356577820378810467527006377296194102671360302059901897977339728292345132827184227155061326328585640019916328847372295754472832318258636054663091475801235050657401857262960415898483713074139212596685365780269667500271108538319</span></span><br><span class="line">print(n-gift*<span class="number">8</span>)</span><br><span class="line">e = <span class="number">54722</span></span><br><span class="line">phi=gift*<span class="number">8</span></span><br><span class="line">print(gcd(e,phi))</span><br><span class="line">e=e//<span class="number">2</span></span><br><span class="line">d=invert(e,phi)</span><br><span class="line">m=pow(c,int(d),n)</span><br><span class="line">mm=iroot(m,<span class="number">2</span>)[<span class="number">0</span>]</span><br><span class="line">print(long_to_bytes(mm))</span><br></pre></td></tr></table></figure>

<h2 id="flag"><a href="#flag" class="headerlink" title="flag"></a>flag</h2><p>NPUCTF{diff1cult_rsa_1s_e@sy}</p>
<h1 id="0x02-rsa-roar-babyrsa"><a href="#0x02-rsa-roar-babyrsa" class="headerlink" title="0x02. rsa roar babyrsa"></a>0x02. rsa roar babyrsa</h1><h2 id="题目源码"><a href="#题目源码" class="headerlink" title="题目源码"></a>题目源码</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> sympy</span><br><span class="line"><span class="keyword">import</span> random</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">myGetPrime</span><span class="params">()</span>:</span></span><br><span class="line">    A= getPrime(<span class="number">513</span>)</span><br><span class="line">    print(A)</span><br><span class="line">    B=A-random.randint(<span class="number">1e3</span>,<span class="number">1e5</span>)</span><br><span class="line">    print(B)</span><br><span class="line">    <span class="keyword">return</span> sympy.nextPrime((B!)%A)</span><br><span class="line">p=myGetPrime()</span><br><span class="line"><span class="comment">#A1=21856963452461630437348278434191434000066076750419027493852463513469865262064340836613831066602300959772632397773487317560339056658299954464169264467234407</span></span><br><span class="line"><span class="comment">#B1=21856963452461630437348278434191434000066076750419027493852463513469865262064340836613831066602300959772632397773487317560339056658299954464169264467140596</span></span><br><span class="line"></span><br><span class="line">q=myGetPrime()</span><br><span class="line"><span class="comment">#A2=16466113115839228119767887899308820025749260933863446888224167169857612178664139545726340867406790754560227516013796269941438076818194617030304851858418927</span></span><br><span class="line"><span class="comment">#B2=16466113115839228119767887899308820025749260933863446888224167169857612178664139545726340867406790754560227516013796269941438076818194617030304851858351026</span></span><br><span class="line"></span><br><span class="line">r=myGetPrime()</span><br><span class="line"></span><br><span class="line">n=p*q*r</span><br><span class="line"><span class="comment">#n=85492663786275292159831603391083876175149354309327673008716627650718160585639723100793347534649628330416631255660901307533909900431413447524262332232659153047067908693481947121069070451562822417357656432171870951184673132554213690123308042697361969986360375060954702920656364144154145812838558365334172935931441424096270206140691814662318562696925767991937369782627908408239087358033165410020690152067715711112732252038588432896758405898709010342467882264362733</span></span><br><span class="line">c=pow(flag,e,n)</span><br><span class="line"><span class="comment">#e=0x1001</span></span><br><span class="line"><span class="comment">#c=75700883021669577739329316795450706204502635802310731477156998834710820770245219468703245302009998932067080383977560299708060476222089630209972629755965140317526034680452483360917378812244365884527186056341888615564335560765053550155758362271622330017433403027261127561225585912484777829588501213961110690451987625502701331485141639684356427316905122995759825241133872734362716041819819948645662803292418802204430874521342108413623635150475963121220095236776428</span></span><br><span class="line"><span class="comment">#so,what is the flag?</span></span><br></pre></td></tr></table></figure>

<h2 id="解题原理-1"><a href="#解题原理-1" class="headerlink" title="解题原理"></a>解题原理</h2><p>当且仅当p为素数时：( p -1 )! ≡ -1 ( mod p )。<br>阶乘只乘到 B ，所以把（B+1）乘到（A-1）这一段也补上就得到了威尔逊公式，反之我们可以由用 -1 乘这一段的模反数，就得到了题目中的 (B!)%A 。</p>
<h2 id="解题代码-1"><a href="#解题代码-1" class="headerlink" title="解题代码"></a>解题代码</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> Crypto.Util.number <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> sympy <span class="keyword">import</span> nextprime</span><br><span class="line">A1=<span class="number">21856963452461630437348278434191434000066076750419027493852463513469865262064340836613831066602300959772632397773487317560339056658299954464169264467234407</span></span><br><span class="line">B1=<span class="number">21856963452461630437348278434191434000066076750419027493852463513469865262064340836613831066602300959772632397773487317560339056658299954464169264467140596</span></span><br><span class="line"></span><br><span class="line">A2=<span class="number">16466113115839228119767887899308820025749260933863446888224167169857612178664139545726340867406790754560227516013796269941438076818194617030304851858418927</span></span><br><span class="line">B2=<span class="number">16466113115839228119767887899308820025749260933863446888224167169857612178664139545726340867406790754560227516013796269941438076818194617030304851858351026</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">f</span><span class="params">(a,b,P)</span>:</span><span class="comment"># a*(a+1)*...*b  (mod P)</span></span><br><span class="line">    ans=<span class="number">1</span></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(a,b+<span class="number">1</span>):</span><br><span class="line">        ans*=i</span><br><span class="line">        ans%=P</span><br><span class="line">    <span class="keyword">return</span> ans%P</span><br><span class="line"></span><br><span class="line">inv1=inverse(f(B1+<span class="number">1</span>,A1<span class="number">-1</span>,A1),A1)</span><br><span class="line">ans1=((A1<span class="number">-1</span>)*inv1)%A1</span><br><span class="line">p=nextprime(ans1)</span><br><span class="line"></span><br><span class="line">inv2=inverse(f(B2+<span class="number">1</span>,A2<span class="number">-1</span>,A2),A2)</span><br><span class="line">ans2=((A2<span class="number">-1</span>)*inv2)%A2</span><br><span class="line">q=nextprime(ans2)</span><br><span class="line"></span><br><span class="line">e=<span class="number">0x1001</span></span><br><span class="line">c=<span class="number">75700883021669577739329316795450706204502635802310731477156998834710820770245219468703245302009998932067080383977560299708060476222089630209972629755965140317526034680452483360917378812244365884527186056341888615564335560765053550155758362271622330017433403027261127561225585912484777829588501213961110690451987625502701331485141639684356427316905122995759825241133872734362716041819819948645662803292418802204430874521342108413623635150475963121220095236776428</span></span><br><span class="line">n=<span class="number">85492663786275292159831603391083876175149354309327673008716627650718160585639723100793347534649628330416631255660901307533909900431413447524262332232659153047067908693481947121069070451562822417357656432171870951184673132554213690123308042697361969986360375060954702920656364144154145812838558365334172935931441424096270206140691814662318562696925767991937369782627908408239087358033165410020690152067715711112732252038588432896758405898709010342467882264362733</span></span><br><span class="line"></span><br><span class="line">r=(n//p)//q</span><br><span class="line"><span class="keyword">assert</span> isPrime(r)</span><br><span class="line">d=inverse(e,(p<span class="number">-1</span>)*(q<span class="number">-1</span>)*(r<span class="number">-1</span>))</span><br><span class="line">m=pow(c,d,n)</span><br><span class="line">print(long_to_bytes(m))</span><br></pre></td></tr></table></figure>

<h2 id="flag-1"><a href="#flag-1" class="headerlink" title="flag"></a>flag</h2><p>RoarCTF{wm-CongrAtu1ation4-1t4-ju4t-A-bAby-R4A}</p>
<h1 id="0x03-rsa-roar-rsa1"><a href="#0x03-rsa-roar-rsa1" class="headerlink" title="0x03. rsa roar rsa1"></a>0x03. rsa roar rsa1</h1><h2 id="题目源码-1"><a href="#题目源码-1" class="headerlink" title="题目源码"></a>题目源码</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">A=(((y%x)**<span class="number">5</span>)%(x%y))**<span class="number">2019</span>+y**<span class="number">316</span>+(y+<span class="number">1</span>)/x</span><br><span class="line">p=next_prime(z*x*y)</span><br><span class="line">q=next_prime(z)</span><br><span class="line">A =  <span class="number">2683349182678714524247469512793476009861014781004924905484127480308161377768192868061561886577048646432382128960881487463427414176114486885830693959404989743229103516924432512724195654425703453612710310587164417035878308390676612592848750287387318129424195208623440294647817367740878211949147526287091298307480502897462279102572556822231669438279317474828479089719046386411971105448723910594710418093977044179949800373224354729179833393219827789389078869290217569511230868967647963089430594258815146362187250855166897553056073744582946148472068334167445499314471518357535261186318756327890016183228412253724</span></span><br><span class="line">n =  <span class="number">117930806043507374325982291823027285148807239117987369609583515353889814856088099671454394340816761242974462268435911765045576377767711593100416932019831889059333166946263184861287975722954992219766493089630810876984781113645362450398009234556085330943125568377741065242183073882558834603430862598066786475299918395341014877416901185392905676043795425126968745185649565106322336954427505104906770493155723995382318346714944184577894150229037758434597242564815299174950147754426950251419204917376517360505024549691723683358170823416757973059354784142601436519500811159036795034676360028928301979780528294114933347127</span></span><br><span class="line">c =  <span class="number">41971850275428383625653350824107291609587853887037624239544762751558838294718672159979929266922528917912189124713273673948051464226519605803745171340724343705832198554680196798623263806617998072496026019940476324971696928551159371970207365741517064295956376809297272541800647747885170905737868568000101029143923792003486793278197051326716680212726111099439262589341050943913401067673851885114314709706016622157285023272496793595281054074260451116213815934843317894898883215362289599366101018081513215120728297131352439066930452281829446586562062242527329672575620261776042653626411730955819001674118193293313612128</span></span><br></pre></td></tr></table></figure>
<h2 id="解题原理-2"><a href="#解题原理-2" class="headerlink" title="解题原理"></a>解题原理</h2><h2 id="解题代码-2"><a href="#解题代码-2" class="headerlink" title="解题代码"></a>解题代码</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> gmpy2</span><br><span class="line"><span class="keyword">import</span> sympy</span><br><span class="line"><span class="keyword">from</span> Crypto.Util.number <span class="keyword">import</span> long_to_bytes</span><br><span class="line"></span><br><span class="line">A =  <span class="number">2683349182678714524247469512793476009861014781004924905484127480308161377768192868061561886577048646432382128960881487463427414176114486885830693959404989743229103516924432512724195654425703453612710310587164417035878308390676612592848750287387318129424195208623440294647817367740878211949147526287091298307480502897462279102572556822231669438279317474828479089719046386411971105448723910594710418093977044179949800373224354729179833393219827789389078869290217569511230868967647963089430594258815146362187250855166897553056073744582946148472068334167445499314471518357535261186318756327890016183228412253724</span></span><br><span class="line">n =  <span class="number">117930806043507374325982291823027285148807239117987369609583515353889814856088099671454394340816761242974462268435911765045576377767711593100416932019831889059333166946263184861287975722954992219766493089630810876984781113645362450398009234556085330943125568377741065242183073882558834603430862598066786475299918395341014877416901185392905676043795425126968745185649565106322336954427505104906770493155723995382318346714944184577894150229037758434597242564815299174950147754426950251419204917376517360505024549691723683358170823416757973059354784142601436519500811159036795034676360028928301979780528294114933347127</span></span><br><span class="line">c =  <span class="number">41971850275428383625653350824107291609587853887037624239544762751558838294718672159979929266922528917912189124713273673948051464226519605803745171340724343705832198554680196798623263806617998072496026019940476324971696928551159371970207365741517064295956376809297272541800647747885170905737868568000101029143923792003486793278197051326716680212726111099439262589341050943913401067673851885114314709706016622157285023272496793595281054074260451116213815934843317894898883215362289599366101018081513215120728297131352439066930452281829446586562062242527329672575620261776042653626411730955819001674118193293313612128</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#暴力算出x和y的值</span></span><br><span class="line">x=<span class="number">0</span></span><br><span class="line">y=<span class="number">0</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> range(<span class="number">2</span>,<span class="number">200</span>):</span><br><span class="line">    <span class="keyword">for</span> j <span class="keyword">in</span> range(<span class="number">2</span>,<span class="number">200</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            <span class="keyword">if</span> (((j%i)**<span class="number">5</span>)%(i%j))**<span class="number">2019</span>+j**<span class="number">316</span>+(j+<span class="number">1</span>)//i == A:</span><br><span class="line">                x=i</span><br><span class="line">                y=j</span><br><span class="line">                <span class="keyword">break</span></span><br><span class="line">        <span class="keyword">except</span>:</span><br><span class="line">            <span class="keyword">pass</span></span><br><span class="line"></span><br><span class="line">print(x,y)</span><br><span class="line"><span class="keyword">if</span>(x==<span class="number">0</span> <span class="keyword">or</span> y==<span class="number">0</span>) :</span><br><span class="line">    exit()</span><br><span class="line"></span><br><span class="line"><span class="comment">#算出p和q</span></span><br><span class="line">n1 = n//(x*y)</span><br><span class="line">np = (gmpy2.iroot(n1,<span class="number">2</span>))[<span class="number">0</span>]</span><br><span class="line">p = sympy.nextprime(np)</span><br><span class="line">q = n//p</span><br><span class="line"></span><br><span class="line">print(q,<span class="string">"\n"</span>,p)</span><br><span class="line"></span><br><span class="line">e=<span class="number">65537</span></span><br><span class="line"></span><br><span class="line">n=p*q</span><br><span class="line">phin=(p<span class="number">-1</span>)*(q<span class="number">-1</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">while</span>(e&lt;<span class="number">0x10003</span>): </span><br><span class="line">    <span class="keyword">try</span>:</span><br><span class="line">        d=gmpy2.invert(e,phin)</span><br><span class="line">        m=pow(c,d,n)</span><br><span class="line">        flag = long_to_bytes(m)</span><br><span class="line">        print(flag)</span><br><span class="line">        <span class="keyword">break</span>        </span><br><span class="line">    <span class="keyword">except</span>:</span><br><span class="line">        <span class="keyword">pass</span></span><br><span class="line">    e = sympy.nextprime(e)      </span><br></pre></td></tr></table></figure>
<h2 id="flag-2"><a href="#flag-2" class="headerlink" title="flag"></a>flag</h2><p>RoarCTF{wm-l1l1ll1l1l1l111ll}</p>
<h1 id="0x04-common-rsa"><a href="#0x04-common-rsa" class="headerlink" title="0x04. common rsa"></a>0x04. common rsa</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> Crypto.Util.number <span class="keyword">import</span> getPrime, bytes_to_long</span><br><span class="line"><span class="keyword">import</span> gmpy2</span><br><span class="line"><span class="keyword">from</span> secret <span class="keyword">import</span> hint,flag</span><br><span class="line"></span><br><span class="line"><span class="keyword">assert</span> len(hint)==<span class="number">28</span></span><br><span class="line"></span><br><span class="line">p, q = getPrime(<span class="number">1024</span>), getPrime(<span class="number">1024</span>)</span><br><span class="line">N = p * q</span><br><span class="line"><span class="comment"># N = 13210885841475518997568732164505399160965975732709166440636514294147889012939962719747539825751923393125345841105194204835106865501597494306950242851021806919844457001207940087403826453676960820293604664852256329422339043270905696645969167335653171499672006516853649796861604166761519002960115698076234349938629174196811631219016260092670861554168242659812550025656836617235464100043662486564305360514744784304117455647758598410090081092904051134426154172210241012032835402789503490147182192969447649332989505033061036275185561204430838918866613413178664432425710430112085580833238357752115397317954683681495273481389</span></span><br><span class="line">lam = gmpy2.lcm(p<span class="number">-1</span>, q<span class="number">-1</span>)</span><br><span class="line">d1, d2 = getPrime(<span class="number">700</span>), getPrime(<span class="number">700</span>)</span><br><span class="line">e1, e2 = gmpy2.invert(d1, lam), gmpy2.invert(d2, lam)</span><br><span class="line"><span class="comment"># e1 = 2362084139893405093100851500036437427130753588874770144214789282673606056995400452788220040281778791657867579436414252823552777228138008313512389117391660371862515728725314731064077161987981532020815534191123548980295455247064358562847786091773315905741298461223652815627950324240999370034314278563662587111397996345472564435937644492350734358340274983731113113635179437404528435163643061230423800728267343681110923935960537320270088154823842363204982299121314474873903268514696308154685325185965860497240479658442957806291665318879425962161464553028085194356710217166887400805442731868081113238642645694081223918279</span></span><br><span class="line"><span class="comment"># e2 = 3414563644994824673043321903579545055064146345197255378925441682500004270176946976155926310465466980633244227451321649151667496995568059258205501094869245772888762971415898595773497552721465370122131433357444025304164265928843912360131588986154074442926163483255945248639016376316121291379194754917958825314218152923102469383434911228730021468050093165348698614766633636600000928215593854869167057725013823299777115974128549538363855171997713965108293531424982357531477437917670830142806697234090847241145606725000986664742983223795093957257772115045975670612945728721064289031105561620681130223256874848014328627387</span></span><br><span class="line">m = bytes_to_long(flag)</span><br><span class="line">c = pow(m, <span class="number">65537</span>, N)</span><br><span class="line"><span class="comment"># c = 7509553860783555621436770331937084571808765391952325412927571489888110953335079989946907174565869802637698429436373777452178173489559054167708787358950733332569061899871857436220178404228920207316305775763298358672742916672692448339586826683320641684274797705468243189922260974401036329516370582452616835330578465913847623960113615530202243536961528874664359484225419012604926739741446652801517754617125097714308718696159416774441152786882175474276850952376624168400656872284235826980641374657158962776898393544419094412396806119989817549523336265300100681211520861433014873204547877014541979273900480702892070278171</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#p1, q1 = getPrime(1024), getPrime(1024)</span></span><br><span class="line"><span class="comment">#N1 = p1 * q1</span></span><br><span class="line"><span class="comment">#p0 = p1 ^ (bytes_to_long(hint)&lt;&lt;444)</span></span><br><span class="line"><span class="comment">#assert N1==22752894188316360092540975721906836497991847739424447868959786578153887300450204451741779348632585992639813683087014583667437383610183725778340014971884694702424840759289252997193997614461702362265455177683286566007629947557111478254578643051667900283702126832059297887141543875571396701604215946728406574474496523342528156416445367009267837915658813685925782997542357007012092288854590169727090121416037455857985211971777796742820802720844285182550822546485833511721384166383556717318973404935286135274368441649494487024480611465888320197131493458343887388661805459986546580104914535886977559349182684565216141697843L</span></span><br><span class="line"><span class="comment">#assert p0==165268930359949857026074503377557908247892339573941373503738312676595180929705525120390798235341002232499096629250002305840384250879180463692771724228098578839654230711801010511101603925719055251331144950208399022480638167824839670035053131870941541955431984347563680229468562579668449565647313503239028017367L</span></span><br></pre></td></tr></table></figure>

<h2 id="解题"><a href="#解题" class="headerlink" title="解题"></a>解题</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!/usr/local/bin/sage -python</span></span><br><span class="line"><span class="keyword">from</span> sage.all <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> Crypto.Util.number <span class="keyword">import</span> long_to_bytes</span><br><span class="line"><span class="keyword">import</span> gmpy2</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">N1 = <span class="number">22752894188316360092540975721906836497991847739424447868959786578153887300450204451741779348632585992639813683087014583667437383610183725778340014971884694702424840759289252997193997614461702362265455177683286566007629947557111478254578643051667900283702126832059297887141543875571396701604215946728406574474496523342528156416445367009267837915658813685925782997542357007012092288854590169727090121416037455857985211971777796742820802720844285182550822546485833511721384166383556717318973404935286135274368441649494487024480611465888320197131493458343887388661805459986546580104914535886977559349182684565216141697843</span></span><br><span class="line">p0 = <span class="number">165268930359949857026074503377557908247892339573941373503738312676595180929705525120390798235341002232499096629250002305840384250879180463692771724228098578839654230711801010511101603925719055251331144950208399022480638167824839670035053131870941541955431984347563680229468562579668449565647313503239028017367</span></span><br><span class="line"><span class="comment"># Different parameters for each team</span></span><br><span class="line">N = <span class="number">21449895719826316652446571946981952001870566997635249354839719104586793422147136850745824964669880149217071660375357131860682282796961273035757913027221984662855086934378108862417739678560641256025021177459341664799202908015371506818482697948776860635401930560813387486994329880316276005206046676604369818653109492798511157267685062757615124902736832428778894091595763452172598515654092085157566254905703036750059426372678012021690115369113601765685996153603249713637184151546264425226874180985930269362876845015270912918849008772950078638461376666258348157307814840090503490728994671500681702766815576953787813978261</span></span><br><span class="line">e1 = <span class="number">154876861410030193905637296965209391737518615267603515377282161163927291285967965497209788803884091512203071770629845496583933653022795932154979438702329298506942119286672966860218225280626597363420844895229952830077688654634909597435821159150203935892844897371875699700527646518533561853297444882053983227593488765684563676352563626896826395039059975553220690136832152388058883795799274080376167383757159656303732365134738082284498670076819991548527840704114978992615193815662908944493989239004523225764813567930483040425975604255002646785221221878939420219915361396619167751523362930788604016988652824182040859853</span></span><br><span class="line">e2 = <span class="number">402990417892531977850271294939175215561881274701367217938141276378027299932263277333257773304557909966758931404723788571151364295341508924840669170504985457120360059297598604537100046622550945605718236227573083837228605402001910225151380616962871923554321544941879414420770210243790557120014475150848993651449636282584509883109795086026235707304394495245201159365863786851663410631339564797425347542642297764418117149471025357391362626205617684148715868071334593025123520727806776519925478240637301296453177836917692916152818769174676318043128314246927769799960281108858830520315473333109470979129926160732972172081</span></span><br><span class="line">c = <span class="number">21037638775241935705441169753441969181214988969805330775013543248627632552311198450678114235819562675518919466977321520345880402152065754456138008928612618730995007509860931974158286638375767596664571588900873546529219194178268112698039853957041774843749061288696704191382908696861582667493389648259168539280602684104107043926115007135814623174879703368347247535365452080470946340175647350659950178146229633608967125085585415972497659100238875587736956198682668140956431794164348384880775647438732698709407480919045992477653549924142632962331437675488780736097081752111600358026119501809787360220615860538667734006333</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">_p = p0 - (p0&amp;(<span class="number">2</span>**<span class="number">668</span><span class="number">-2</span>**<span class="number">444</span>))</span><br><span class="line">PR = PolynomialRing(Zmod(N1), <span class="string">'x'</span>)</span><br><span class="line">x = PR.gen()</span><br><span class="line">f = <span class="number">2</span>**<span class="number">444</span> * x + _p</span><br><span class="line">f = f.monic()</span><br><span class="line">r = f.small_roots(X=<span class="number">2</span>**<span class="number">224</span>, beta=<span class="number">0.5</span>)</span><br><span class="line">p1 = ZZ(_p + r[<span class="number">0</span>]*<span class="number">2</span>**<span class="number">444</span>)</span><br><span class="line">hint = ( p1.__xor__(p0) )&gt;&gt;<span class="number">444</span></span><br><span class="line"><span class="keyword">print</span> (<span class="string">'hint: '</span> , long_to_bytes(hint))</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">alpha2 = <span class="number">700.</span>/<span class="number">2048</span></span><br><span class="line">M1 = int(gmpy2.mpz(N)**<span class="number">0.5</span>)</span><br><span class="line">M2 = int( gmpy2.mpz(N)**(<span class="number">1</span>+alpha2) )</span><br><span class="line">D = diagonal_matrix(ZZ, [N, M1, M2, <span class="number">1</span>])</span><br><span class="line">B = Matrix(ZZ, [ [<span class="number">1</span>, -N,   <span class="number">0</span>,  N**<span class="number">2</span>],</span><br><span class="line">                 [<span class="number">0</span>, e1, -e1, -e1*N],</span><br><span class="line">                 [<span class="number">0</span>,  <span class="number">0</span>,  e2, -e2*N],</span><br><span class="line">                 [<span class="number">0</span>,  <span class="number">0</span>,   <span class="number">0</span>, e1*e2] ]) * D</span><br><span class="line"></span><br><span class="line">L = B.LLL()</span><br><span class="line"></span><br><span class="line">v = Matrix(ZZ, L[<span class="number">0</span>])</span><br><span class="line">x = v * B**(<span class="number">-1</span>)</span><br><span class="line">phi = (x[<span class="number">0</span>,<span class="number">1</span>]/x[<span class="number">0</span>,<span class="number">0</span>]*e1).floor()</span><br><span class="line"></span><br><span class="line">PR = PolynomialRing(ZZ, <span class="string">'x'</span>)</span><br><span class="line">x = PR.gen()</span><br><span class="line">f = x**<span class="number">2</span> - (N-phi+<span class="number">1</span>)*x + N</span><br><span class="line">p, q = f.roots()[<span class="number">0</span>][<span class="number">0</span>], f.roots()[<span class="number">1</span>][<span class="number">0</span>]</span><br><span class="line"></span><br><span class="line">d = inverse_mod( <span class="number">65537</span>, (p<span class="number">-1</span>)*(q<span class="number">-1</span>) )</span><br><span class="line">m = power_mod(c, d, N)</span><br><span class="line"><span class="keyword">print</span> (<span class="string">'flag: '</span> , long_to_bytes(m))</span><br></pre></td></tr></table></figure>
<h2 id="flag-3"><a href="#flag-3" class="headerlink" title="flag"></a>flag</h2><p>hint:  b’3-540-46701-7_14 or 2009/037’<br>flag:  b’d3ctf{Extend1NG<del>WiEneR</del>$_AtT@Ck~-I274679C9CC2}’</p>
<h1 id="0x05-lattice-based-attack-on-common-private-Exponent-RSA"><a href="#0x05-lattice-based-attack-on-common-private-Exponent-RSA" class="headerlink" title="0x05. lattice_based_attack_on_common_private_Exponent_RSA"></a>0x05. lattice_based_attack_on_common_private_Exponent_RSA</h1><h2 id="原题"><a href="#原题" class="headerlink" title="原题"></a>原题</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> Crypto.Util.number <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> random <span class="keyword">import</span> randint</span><br><span class="line"></span><br><span class="line">flag = bytes_to_long()</span><br><span class="line">d = getPrime(randint(<span class="number">380</span>, <span class="number">385</span>))</span><br><span class="line"><span class="comment"># print(d)</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> _ <span class="keyword">in</span> range(<span class="number">3</span>):</span><br><span class="line">    p = getPrime(<span class="number">512</span>)</span><br><span class="line">    q = getPrime(<span class="number">512</span>)</span><br><span class="line">    n = p * q</span><br><span class="line">    fn = (p - <span class="number">1</span>) * (q - <span class="number">1</span>)</span><br><span class="line">    e = inverse(d, fn)</span><br><span class="line">    c = pow(flag, e, n)</span><br><span class="line">    print(<span class="string">'e'</span>+str(_)+str(<span class="string">'='</span>)+hex(e))</span><br><span class="line">    print(<span class="string">'n'</span>+str(_)+str(<span class="string">'='</span>)+hex(n))</span><br><span class="line">    print(<span class="string">'c'</span>+str(_)+str(<span class="string">'='</span>)+hex(c))</span><br><span class="line">    </span><br><span class="line">e0=<span class="number">0x6cce6ac75c2cc5a424aa964e99d65910f235b6204ec34b98d0e6636cd1576d3e2167bec8bd9be7ee29eff8e641800f3560969dcee86ad8709faa1a3567006052b83baba02795abe9192c32980bb799e4538ec6338bcf43592aa09ea4a741f94c2b6ab5adc08f6b457f9aa9ff0ff5de6461b618c5b64b56f5cd77b58df9cc6b63</span></span><br><span class="line">n0=<span class="number">0x9d7c91d6034230d663f4502299504e38d3680c5baf0e421dcc0e968007e8d293c4a8026795b1b66cf8fec49087e78816b4a910af92108fdb0f90b83dd51e3186dc82f121307792ed3a1f1f194893e8bdca7cdab9f23039b33f5c0c0c2187334426ef238e73263ca2b603ab900dcee91b6dce3243af85747300b91c99e9fdfea3</span></span><br><span class="line">c0=<span class="number">0x686c48c6ba18a823f81adaebf45c2e325fa00b3843fb25225603c2401b5fb773c142d677fb48292f6726468d2cf0dd350ca6dd678d2003a5fc19a4b8f3496ee98614a012eb75a1d4291d5114f51df779eedb7a3667244e5c348160fe0c9f82f8c1440c8791e93baf0b2e3909c9cbde480fc5670e4df1ce69c1331640af405faf</span></span><br><span class="line">e1=<span class="number">0x6690588cdc0956fb9f0561c6a61bab0a56547e96de7e858c8c243ed9b3c9a96256779f0aa420ae175c2ec8051eba86a4b04c4ef67203fd278eceb1e4d3dc29a5b5d65198fe0b975a69da155d2cf1043522880e31307f990265cba09e75c733e6431ad1d9063dfc7d995f88fc7797cc35f76ddf165ed87996ce2d7a31da8d6d8b</span></span><br><span class="line">n1=<span class="number">0x7981e477fa5cb87ba789310b5711f9c1b3c36eee9fbc8c01acc236e3cb55df99babdefb090ea0ef2d225572801f7b95ad47fa96174033b61f70fb3b75ca91e61c279a0b5bd88de4f0a010c9344eebba61e5b5f5388930f169e6e2c3cf1669545ceede0e31f7512996d2c21a91fb44685e5566850032e90f7f1afc51287334125</span></span><br><span class="line">c1=<span class="number">0x3fb530f51deee734bdfa1504d8d2a21df45062aaf9ff204f1db0eaa0c5152d16974eb890b33e65376916cdaf8e0e0511500074fa1f6f83844ec9c80e6203520902efa7fcd0d49b39f0a37ad4064451967e46dc0ee99b31719ee01e1435f35b005d316aafce89cc945499781413bc6734c320ff161e5a7c8885901b2b7cf674a4</span></span><br><span class="line">e2=<span class="number">0x5c037594d01141300be1fb0a3229933dda5be274f24ac52714f7cdafe2d336f01950fe9568d71f59e7604cc9dd51f385f3686dc0eb2523f6c2010cd2221cb628291757ab351f29f9deac2d7dddf492fbfcd425b16c28daf0f491680b13709e26e6d679ec18b82fbf5ebb56728ba75e1839c2fd3bc3f3350b502e7689b1f5a54b</span></span><br><span class="line">n2=<span class="number">0x706c9ed047cee7cc5da315b12939ffff83a2152cebbec0377f1aca29b25cda7244b3459c592dd917a1f12707f9db4c449331a822c53f9b56de0292ce06307644fa8aa088dd7a7069c63c0126b010fed4247139b2b67ada7dca408628ba445551f463b977f7ad47f23c1ffbc1ee443e5d68bef0a2076ff882f5b2feba4d251f07</span></span><br><span class="line">c2=<span class="number">0x3ed44070098207d1dd810eabd8727eccca5a17fc1d272bd0babbc75a43ee1a6611fac2e7d30c1d56a0802a86a8298ceb3aada93ad9f5cb056204cd058994eecd223931c429a97d78cf8577e800237625b7c735ea7f10109241459760d3b42ca5597669636ac344c866e66f75afff23195e28a49adc0acd5ce493063c586e7a86</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="解题-1"><a href="#解题-1" class="headerlink" title="解题"></a>解题</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> base64 <span class="keyword">import</span> b16decode</span><br><span class="line"><span class="keyword">from</span> sage.all <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> Crypto.Util.number <span class="keyword">import</span> long_to_bytes</span><br><span class="line">e0=<span class="number">0x6cce6ac75c2cc5a424aa964e99d65910f235b6204ec34b98d0e6636cd1576d3e2167bec8bd9be7ee29eff8e641800f3560969dcee86ad8709faa1a3567006052b83baba02795abe9192c32980bb799e4538ec6338bcf43592aa09ea4a741f94c2b6ab5adc08f6b457f9aa9ff0ff5de6461b618c5b64b56f5cd77b58df9cc6b63</span></span><br><span class="line">n0=<span class="number">0x9d7c91d6034230d663f4502299504e38d3680c5baf0e421dcc0e968007e8d293c4a8026795b1b66cf8fec49087e78816b4a910af92108fdb0f90b83dd51e3186dc82f121307792ed3a1f1f194893e8bdca7cdab9f23039b33f5c0c0c2187334426ef238e73263ca2b603ab900dcee91b6dce3243af85747300b91c99e9fdfea3</span></span><br><span class="line">c0=<span class="number">0x686c48c6ba18a823f81adaebf45c2e325fa00b3843fb25225603c2401b5fb773c142d677fb48292f6726468d2cf0dd350ca6dd678d2003a5fc19a4b8f3496ee98614a012eb75a1d4291d5114f51df779eedb7a3667244e5c348160fe0c9f82f8c1440c8791e93baf0b2e3909c9cbde480fc5670e4df1ce69c1331640af405faf</span></span><br><span class="line">e1=<span class="number">0x6690588cdc0956fb9f0561c6a61bab0a56547e96de7e858c8c243ed9b3c9a96256779f0aa420ae175c2ec8051eba86a4b04c4ef67203fd278eceb1e4d3dc29a5b5d65198fe0b975a69da155d2cf1043522880e31307f990265cba09e75c733e6431ad1d9063dfc7d995f88fc7797cc35f76ddf165ed87996ce2d7a31da8d6d8b</span></span><br><span class="line">n1=<span class="number">0x7981e477fa5cb87ba789310b5711f9c1b3c36eee9fbc8c01acc236e3cb55df99babdefb090ea0ef2d225572801f7b95ad47fa96174033b61f70fb3b75ca91e61c279a0b5bd88de4f0a010c9344eebba61e5b5f5388930f169e6e2c3cf1669545ceede0e31f7512996d2c21a91fb44685e5566850032e90f7f1afc51287334125</span></span><br><span class="line">c1=<span class="number">0x3fb530f51deee734bdfa1504d8d2a21df45062aaf9ff204f1db0eaa0c5152d16974eb890b33e65376916cdaf8e0e0511500074fa1f6f83844ec9c80e6203520902efa7fcd0d49b39f0a37ad4064451967e46dc0ee99b31719ee01e1435f35b005d316aafce89cc945499781413bc6734c320ff161e5a7c8885901b2b7cf674a4</span></span><br><span class="line">e2=<span class="number">0x5c037594d01141300be1fb0a3229933dda5be274f24ac52714f7cdafe2d336f01950fe9568d71f59e7604cc9dd51f385f3686dc0eb2523f6c2010cd2221cb628291757ab351f29f9deac2d7dddf492fbfcd425b16c28daf0f491680b13709e26e6d679ec18b82fbf5ebb56728ba75e1839c2fd3bc3f3350b502e7689b1f5a54b</span></span><br><span class="line">n2=<span class="number">0x706c9ed047cee7cc5da315b12939ffff83a2152cebbec0377f1aca29b25cda7244b3459c592dd917a1f12707f9db4c449331a822c53f9b56de0292ce06307644fa8aa088dd7a7069c63c0126b010fed4247139b2b67ada7dca408628ba445551f463b977f7ad47f23c1ffbc1ee443e5d68bef0a2076ff882f5b2feba4d251f07</span></span><br><span class="line">c2=<span class="number">0x3ed44070098207d1dd810eabd8727eccca5a17fc1d272bd0babbc75a43ee1a6611fac2e7d30c1d56a0802a86a8298ceb3aada93ad9f5cb056204cd058994eecd223931c429a97d78cf8577e800237625b7c735ea7f10109241459760d3b42ca5597669636ac344c866e66f75afff23195e28a49adc0acd5ce493063c586e7a86</span></span><br><span class="line"></span><br><span class="line">M = matrix(<span class="number">4</span>,<span class="number">4</span>)</span><br><span class="line">M[<span class="number">0</span>,<span class="number">0</span>] = floor(max([n0,n1,n2])**(<span class="number">1</span>/<span class="number">2</span>))</span><br><span class="line"></span><br><span class="line">M[<span class="number">0</span>,<span class="number">1</span>] = e2</span><br><span class="line">M[<span class="number">1</span>,<span class="number">1</span>] = -n2</span><br><span class="line"></span><br><span class="line">M[<span class="number">0</span>,<span class="number">2</span>] = e1</span><br><span class="line">M[<span class="number">2</span>,<span class="number">2</span>] = -n1</span><br><span class="line"></span><br><span class="line">M[<span class="number">0</span>,<span class="number">3</span>] = e0</span><br><span class="line">M[<span class="number">3</span>,<span class="number">3</span>] = -n0</span><br><span class="line"></span><br><span class="line">S = M.LLL()</span><br><span class="line">d = abs(Integer(S[<span class="number">0</span>][<span class="number">0</span>]))// Integer(M[<span class="number">0</span>][<span class="number">0</span>])</span><br><span class="line">flag=power_mod(Integer(c0),Integer(d),Integer(n0))</span><br><span class="line">print(long_to_bytes(flag))</span><br></pre></td></tr></table></figure>

<h2 id="flag-4"><a href="#flag-4" class="headerlink" title="flag"></a>flag</h2><p>flag{test_flag}</p>
<h1 id="0x06-NTRU-Encrypt-Lattice-attack"><a href="#0x06-NTRU-Encrypt-Lattice-attack" class="headerlink" title="0x06. NTRU_Encrypt_Lattice_attack"></a>0x06. NTRU_Encrypt_Lattice_attack</h1><h2 id="原题-1"><a href="#原题-1" class="headerlink" title="原题"></a>原题</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> base64 <span class="keyword">import</span> b16encode</span><br><span class="line"></span><br><span class="line">Zx.&lt;x&gt; = ZZ[]</span><br><span class="line">n = <span class="number">109</span> </span><br><span class="line">q = <span class="number">2048</span></span><br><span class="line">p = <span class="number">3</span></span><br><span class="line">Df = <span class="number">9</span></span><br><span class="line">Dg = <span class="number">10</span></span><br><span class="line">Dr = <span class="number">11</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">mul</span><span class="params">(f,g)</span>:</span></span><br><span class="line">    <span class="keyword">return</span> (f * g) % (x^n<span class="number">-1</span>)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">bal_mod</span><span class="params">(f,q)</span>:</span></span><br><span class="line">    g = list(((f[i] + q//<span class="number">2</span>) % q) - q//<span class="number">2</span> <span class="keyword">for</span> i <span class="keyword">in</span> range(n))</span><br><span class="line">    <span class="keyword">return</span> Zx(g)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">random_poly</span><span class="params">(d)</span>:</span></span><br><span class="line">    <span class="keyword">assert</span> d &lt;= n</span><br><span class="line">    result = n*[<span class="number">0</span>]</span><br><span class="line">    <span class="keyword">for</span> j <span class="keyword">in</span> range(d):</span><br><span class="line">        <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">            r = randrange(n)</span><br><span class="line">            <span class="keyword">if</span> <span class="keyword">not</span> result[r]: <span class="keyword">break</span></span><br><span class="line">        result[r] = <span class="number">1</span><span class="number">-2</span>*randrange(<span class="number">2</span>)</span><br><span class="line">    <span class="keyword">return</span> Zx(result)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">inv_mod_prime</span><span class="params">(f,p)</span>:</span></span><br><span class="line">    T = Zx.change_ring(Integers(p)).quotient(x^n<span class="number">-1</span>)</span><br><span class="line">    <span class="keyword">return</span> Zx(lift(<span class="number">1</span> / T(f)))</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">inv_mod_powerof2</span><span class="params">(f,q)</span>:</span></span><br><span class="line">    <span class="keyword">assert</span> q.is_power_of(<span class="number">2</span>)</span><br><span class="line">    g = inv_mod_prime(f,<span class="number">2</span>)</span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        r = bal_mod(mul(g,f),q)</span><br><span class="line">        <span class="keyword">if</span> r == <span class="number">1</span>: <span class="keyword">return</span> g</span><br><span class="line">        g = bal_mod(mul(g,<span class="number">2</span> - r),q)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">keygen</span><span class="params">()</span>:</span></span><br><span class="line">    f = random_poly(Df)</span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            fp = inv_mod_prime(f,p)</span><br><span class="line">            fq = inv_mod_powerof2(f,q)</span><br><span class="line">            <span class="keyword">break</span></span><br><span class="line">        <span class="keyword">except</span>:</span><br><span class="line">            f = random_poly(Df)</span><br><span class="line">    g = random_poly(Dg)</span><br><span class="line">    h = bal_mod(p * mul(fq,g),q)</span><br><span class="line">    pub_key = h</span><br><span class="line">    pri_key = [f,fp]</span><br><span class="line">    <span class="keyword">return</span> pub_key,pri_key</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">encrypt</span><span class="params">(m,h)</span>:</span></span><br><span class="line">    r = random_poly(Dr)</span><br><span class="line">    e = bal_mod(mul(h,r) + m,q)</span><br><span class="line">    <span class="keyword">return</span> e</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">    pub_key,pri_key = keygen()</span><br><span class="line">    m = Zx(list(bin(int(b16encode(flag), <span class="number">16</span>))[<span class="number">2</span>:]))</span><br><span class="line">    print(m)</span><br><span class="line">    e = encrypt(m,pub_key)</span><br><span class="line">    print(<span class="string">'pub_key='</span>)</span><br><span class="line">    print(pub_key)</span><br><span class="line">    print(<span class="string">'e='</span>)</span><br><span class="line">    print(e)</span><br><span class="line"><span class="comment">#pub_key=</span></span><br><span class="line"><span class="comment">#510*x^108 - 840*x^107 - 926*x^106 - 717*x^105 - 374*x^104 - 986*x^103 + 488*x^102 + 119*x^101 - 247*x^100 + 34*x^99 + 751*x^98 - 44*x^97 - 257*x^96 - 749*x^95 + 648*x^94 - 280*x^93 - 585*x^92 - 347*x^91 + 357*x^90 - 451*x^89 - 15*x^88 + 638*x^87 - 624*x^86 - 458*x^85 + 216*x^84 + 36*x^83 - 199*x^82 - 655*x^81 + 258*x^80 + 845*x^79 + 490*x^78 - 272*x^77 + 279*x^76 + 101*x^75 - 580*x^74 - 461*x^73 - 614*x^72 - 171*x^71 - 1012*x^70 + 71*x^69 - 579*x^68 + 290*x^67 + 597*x^66 + 841*x^65 + 35*x^64 - 545*x^63 + 575*x^62 - 665*x^61 + 304*x^60 - 900*x^59 + 428*x^58 - 992*x^57 - 241*x^56 + 953*x^55 - 784*x^54 - 730*x^53 - 317*x^52 + 108*x^51 + 180*x^50 - 881*x^49 - 943*x^48 + 413*x^47 - 898*x^46 + 453*x^45 - 407*x^44 + 153*x^43 - 932*x^42 + 262*x^41 + 874*x^40 - 7*x^39 - 364*x^38 + 98*x^37 - 130*x^36 + 942*x^35 - 845*x^34 - 890*x^33 + 558*x^32 - 791*x^31 - 654*x^30 - 733*x^29 - 171*x^28 - 182*x^27 + 644*x^26 - 18*x^25 + 776*x^24 + 845*x^23 - 675*x^22 - 741*x^21 - 352*x^20 - 143*x^19 - 351*x^18 - 158*x^17 + 671*x^16 + 609*x^15 - 34*x^14 + 811*x^13 - 674*x^12 + 595*x^11 - 1005*x^10 + 855*x^9 + 831*x^8 + 768*x^7 + 133*x^6 - 436*x^5 + 1016*x^4 + 403*x^3 + 904*x^2 + 874*x + 248</span></span><br><span class="line"><span class="comment">#e=</span></span><br><span class="line"><span class="comment">#-453*x^108 - 304*x^107 - 380*x^106 - 7*x^105 - 657*x^104 - 988*x^103 + 219*x^102 - 167*x^101 - 473*x^100 + 63*x^99 - 60*x^98 + 1014*x^97 - 874*x^96 - 846*x^95 + 604*x^94 - 649*x^93 + 18*x^92 - 458*x^91 + 689*x^90 + 80*x^89 - 439*x^88 + 968*x^87 - 834*x^86 - 967*x^85 - 784*x^84 + 496*x^83 - 883*x^82 + 971*x^81 - 242*x^80 + 956*x^79 - 832*x^78 - 587*x^77 + 525*x^76 + 87*x^75 + 464*x^74 + 661*x^73 - 36*x^72 - 14*x^71 + 940*x^70 - 16*x^69 - 277*x^68 + 899*x^67 - 390*x^66 + 441*x^65 + 246*x^64 + 267*x^63 - 395*x^62 + 185*x^61 + 221*x^60 + 466*x^59 + 249*x^58 + 813*x^57 + 116*x^56 - 100*x^55 + 109*x^54 + 579*x^53 + 151*x^52 + 194*x^51 + 364*x^50 - 413*x^49 + 614*x^48 + 367*x^47 + 758*x^46 + 460*x^45 + 162*x^44 + 837*x^43 + 903*x^42 + 896*x^41 - 747*x^40 + 410*x^39 - 928*x^38 - 230*x^37 + 465*x^36 - 496*x^35 - 568*x^34 + 30*x^33 - 158*x^32 + 687*x^31 - 284*x^30 + 794*x^29 - 606*x^28 + 705*x^27 - 37*x^26 + 926*x^25 - 602*x^24 - 442*x^23 - 523*x^22 - 260*x^21 + 530*x^20 - 796*x^19 + 443*x^18 + 902*x^17 - 210*x^16 + 926*x^15 + 785*x^14 + 440*x^13 - 572*x^12 - 268*x^11 - 217*x^10 + 26*x^9 + 866*x^8 + 19*x^7 + 778*x^6 + 923*x^5 - 197*x^4 - 446*x^3 - 202*x^2 - 353*x - 852</span></span><br></pre></td></tr></table></figure>
<h2 id="解题-2"><a href="#解题-2" class="headerlink" title="解题"></a>解题</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> binascii <span class="keyword">import</span> unhexlify</span><br><span class="line">Zx.&lt;x&gt; = ZZ[]</span><br><span class="line">n = <span class="number">109</span></span><br><span class="line">q = <span class="number">2048</span></span><br><span class="line">p = <span class="number">3</span></span><br><span class="line"></span><br><span class="line">pub_key = <span class="number">510</span>*x ^ <span class="number">108</span> - <span class="number">840</span>*x ^ <span class="number">107</span> - <span class="number">926</span>*x ^ <span class="number">106</span> - <span class="number">717</span>*x ^ <span class="number">105</span> - <span class="number">374</span>*x ^ <span class="number">104</span> - <span class="number">986</span>*x ^ <span class="number">103</span> + <span class="number">488</span>*x ^ <span class="number">102</span> + <span class="number">119</span>*x ^ <span class="number">101</span> - <span class="number">247</span>*x ^ <span class="number">100</span> + <span class="number">34</span>*x ^ <span class="number">99</span> + <span class="number">751</span>*x ^ <span class="number">98</span> - <span class="number">44</span>*x ^ <span class="number">97</span> - <span class="number">257</span>*x ^ <span class="number">96</span> - <span class="number">749</span>*x ^ <span class="number">95</span> + <span class="number">648</span>*x ^ <span class="number">94</span> - <span class="number">280</span>*x ^ <span class="number">93</span> - <span class="number">585</span>*x ^ <span class="number">92</span> - <span class="number">347</span>*x ^ <span class="number">91</span> + <span class="number">357</span>*x ^ <span class="number">90</span> - <span class="number">451</span>*x ^ <span class="number">89</span> - <span class="number">15</span>*x ^ <span class="number">88</span> + <span class="number">638</span>*x ^ <span class="number">87</span> - <span class="number">624</span>*x ^ <span class="number">86</span> - <span class="number">458</span>*x ^ <span class="number">85</span> + <span class="number">216</span>*x ^ <span class="number">84</span> + <span class="number">36</span>*x ^ <span class="number">83</span> - <span class="number">199</span>*x ^ <span class="number">82</span> - <span class="number">655</span>*x ^ <span class="number">81</span> + <span class="number">258</span>*x ^ <span class="number">80</span> + <span class="number">845</span>*x ^ <span class="number">79</span> + <span class="number">490</span>*x ^ <span class="number">78</span> - <span class="number">272</span>*x ^ <span class="number">77</span> + <span class="number">279</span>*x ^ <span class="number">76</span> + <span class="number">101</span>*x ^ <span class="number">75</span> - <span class="number">580</span>*x ^ <span class="number">74</span> - <span class="number">461</span>*x ^ <span class="number">73</span> - <span class="number">614</span>*x ^ <span class="number">72</span> - <span class="number">171</span>*x ^ <span class="number">71</span> - <span class="number">1012</span>*x ^ <span class="number">70</span> + <span class="number">71</span>*x ^ <span class="number">69</span> - <span class="number">579</span>*x ^ <span class="number">68</span> + <span class="number">290</span>*x ^ <span class="number">67</span> + <span class="number">597</span>*x ^ <span class="number">66</span> + <span class="number">841</span>*x ^ <span class="number">65</span> + <span class="number">35</span>*x ^ <span class="number">64</span> - <span class="number">545</span>*x ^ <span class="number">63</span> + <span class="number">575</span>*x ^ <span class="number">62</span> - <span class="number">665</span>*x ^ <span class="number">61</span> + <span class="number">304</span>*x ^ <span class="number">60</span> - <span class="number">900</span>*x ^ <span class="number">59</span> + <span class="number">428</span>*x ^ <span class="number">58</span> - <span class="number">992</span>*x ^ <span class="number">57</span> - <span class="number">241</span>*x ^ <span class="number">56</span> + <span class="number">953</span>*x ^ <span class="number">55</span> - <span class="number">784</span>*x ^ <span class="number">54</span> - <span class="number">730</span>*x ^ <span class="number">53</span> - <span class="number">317</span>*x ^ <span class="number">52</span> + <span class="number">108</span>*x ^ <span class="number">51</span> + <span class="number">180</span>*x ^ <span class="number">50</span> - <span class="number">881</span>*x ^ <span class="number">49</span> - <span class="number">943</span>*x ^ <span class="number">48</span> + <span class="number">413</span>*x ^ <span class="number">47</span> - <span class="number">898</span>*x ^ <span class="number">46</span> + <span class="number">453</span>*x ^ <span class="number">45</span> - <span class="number">407</span>*x ^ <span class="number">44</span> + <span class="number">153</span>*x ^ <span class="number">43</span> - <span class="number">932</span>*x ^ <span class="number">42</span> + <span class="number">262</span>*x ^ <span class="number">41</span> + <span class="number">874</span>*x ^ <span class="number">40</span> - <span class="number">7</span>*x ^ <span class="number">39</span> - <span class="number">364</span>*x ^ <span class="number">38</span> + <span class="number">98</span>*x ^ <span class="number">37</span> - <span class="number">130</span>*x ^ <span class="number">36</span> + <span class="number">942</span>*x ^ <span class="number">35</span> - <span class="number">845</span>*x ^ <span class="number">34</span> - <span class="number">890</span>*x ^ <span class="number">33</span> + <span class="number">558</span>*x ^ <span class="number">32</span> - <span class="number">791</span>*x ^ <span class="number">31</span> - <span class="number">654</span>*x ^ <span class="number">30</span> - <span class="number">733</span>*x ^ <span class="number">29</span> - <span class="number">171</span> * x ^ <span class="number">28</span> - <span class="number">182</span>*x ^ <span class="number">27</span> + <span class="number">644</span>*x ^ <span class="number">26</span> - <span class="number">18</span>*x ^ <span class="number">25</span> + <span class="number">776</span>*x ^ <span class="number">24</span> + <span class="number">845</span>*x ^ <span class="number">23</span> - <span class="number">675</span>*x ^ <span class="number">22</span> - <span class="number">741</span>*x ^ <span class="number">21</span> - <span class="number">352</span>*x ^ <span class="number">20</span> - <span class="number">143</span>*x ^ <span class="number">19</span> - <span class="number">351</span>*x ^ <span class="number">18</span> - <span class="number">158</span>*x ^ <span class="number">17</span> + <span class="number">671</span>*x ^ <span class="number">16</span> + <span class="number">609</span>*x ^ <span class="number">15</span> - <span class="number">34</span>*x ^ <span class="number">14</span> + <span class="number">811</span>*x ^ <span class="number">13</span> - <span class="number">674</span>*x ^ <span class="number">12</span> + <span class="number">595</span>*x ^ <span class="number">11</span> - <span class="number">1005</span>*x ^ <span class="number">10</span> + <span class="number">855</span>*x ^ <span class="number">9</span> + <span class="number">831</span>*x ^ <span class="number">8</span> + <span class="number">768</span>*x ^ <span class="number">7</span> + <span class="number">133</span>*x ^ <span class="number">6</span> - <span class="number">436</span>*x ^ <span class="number">5</span> + <span class="number">1016</span> * x ^ <span class="number">4</span> + <span class="number">403</span>*x ^ <span class="number">3</span> + <span class="number">904</span>*x ^ <span class="number">2</span> + <span class="number">874</span>*x + <span class="number">248</span></span><br><span class="line">e = <span class="number">-453</span>*x ^ <span class="number">108</span> - <span class="number">304</span>*x ^ <span class="number">107</span> - <span class="number">380</span>*x ^ <span class="number">106</span> - <span class="number">7</span>*x ^ <span class="number">105</span> - <span class="number">657</span>*x ^ <span class="number">104</span> - <span class="number">988</span>*x ^ <span class="number">103</span> + <span class="number">219</span>*x ^ <span class="number">102</span> - <span class="number">167</span>*x ^ <span class="number">101</span> - <span class="number">473</span>*x ^ <span class="number">100</span> + <span class="number">63</span>*x ^ <span class="number">99</span> - <span class="number">60</span>*x ^ <span class="number">98</span> + <span class="number">1014</span>*x ^ <span class="number">97</span> - <span class="number">874</span>*x ^ <span class="number">96</span> - <span class="number">846</span>*x ^ <span class="number">95</span> + <span class="number">604</span>*x ^ <span class="number">94</span> - <span class="number">649</span>*x ^ <span class="number">93</span> + <span class="number">18</span>*x ^ <span class="number">92</span> - <span class="number">458</span>*x ^ <span class="number">91</span> + <span class="number">689</span>*x ^ <span class="number">90</span> + <span class="number">80</span>*x ^ <span class="number">89</span> - <span class="number">439</span>*x ^ <span class="number">88</span> + <span class="number">968</span>*x ^ <span class="number">87</span> - <span class="number">834</span>*x ^ <span class="number">86</span> - <span class="number">967</span>*x ^ <span class="number">85</span> - <span class="number">784</span>*x ^ <span class="number">84</span> + <span class="number">496</span>*x ^ <span class="number">83</span> - <span class="number">883</span>*x ^ <span class="number">82</span> + <span class="number">971</span>*x ^ <span class="number">81</span> - <span class="number">242</span>*x ^ <span class="number">80</span> + <span class="number">956</span>*x ^ <span class="number">79</span> - <span class="number">832</span>*x ^ <span class="number">78</span> - <span class="number">587</span>*x ^ <span class="number">77</span> + <span class="number">525</span>*x ^ <span class="number">76</span> + <span class="number">87</span>*x ^ <span class="number">75</span> + <span class="number">464</span>*x ^ <span class="number">74</span> + <span class="number">661</span>*x ^ <span class="number">73</span> - <span class="number">36</span>*x ^ <span class="number">72</span> - <span class="number">14</span>*x ^ <span class="number">71</span> + <span class="number">940</span>*x ^ <span class="number">70</span> - <span class="number">16</span>*x ^ <span class="number">69</span> - <span class="number">277</span>*x ^ <span class="number">68</span> + <span class="number">899</span>*x ^ <span class="number">67</span> - <span class="number">390</span>*x ^ <span class="number">66</span> + <span class="number">441</span>*x ^ <span class="number">65</span> + <span class="number">246</span>*x ^ <span class="number">64</span> + <span class="number">267</span>*x ^ <span class="number">63</span> - <span class="number">395</span>*x ^ <span class="number">62</span> + <span class="number">185</span>*x ^ <span class="number">61</span> + <span class="number">221</span>*x ^ <span class="number">60</span> + <span class="number">466</span>*x ^ <span class="number">59</span> + <span class="number">249</span>*x ^ <span class="number">58</span> + <span class="number">813</span>*x ^ <span class="number">57</span> + <span class="number">116</span>*x ^ <span class="number">56</span> - <span class="number">100</span> * x ^ <span class="number">55</span> + <span class="number">109</span>*x ^ <span class="number">54</span> + <span class="number">579</span>*x ^ <span class="number">53</span> + <span class="number">151</span>*x ^ <span class="number">52</span> + <span class="number">194</span>*x ^ <span class="number">51</span> + <span class="number">364</span>*x ^ <span class="number">50</span> - <span class="number">413</span>*x ^ <span class="number">49</span> + <span class="number">614</span>*x ^ <span class="number">48</span> + <span class="number">367</span>*x ^ <span class="number">47</span> + <span class="number">758</span>*x ^ <span class="number">46</span> + <span class="number">460</span>*x ^ <span class="number">45</span> + <span class="number">162</span>*x ^ <span class="number">44</span> + <span class="number">837</span>*x ^ <span class="number">43</span> + <span class="number">903</span>*x ^ <span class="number">42</span> + <span class="number">896</span>*x ^ <span class="number">41</span> - <span class="number">747</span>*x ^ <span class="number">40</span> + <span class="number">410</span>*x ^ <span class="number">39</span> - <span class="number">928</span>*x ^ <span class="number">38</span> - <span class="number">230</span>*x ^ <span class="number">37</span> + <span class="number">465</span>*x ^ <span class="number">36</span> - <span class="number">496</span>*x ^ <span class="number">35</span> - <span class="number">568</span>*x ^ <span class="number">34</span> + <span class="number">30</span>*x ^ <span class="number">33</span> - <span class="number">158</span>*x ^ <span class="number">32</span> + <span class="number">687</span>*x ^ <span class="number">31</span> - <span class="number">284</span>*x ^ <span class="number">30</span> + <span class="number">794</span>*x ^ <span class="number">29</span> - <span class="number">606</span> * x ^ <span class="number">28</span> + <span class="number">705</span>*x ^ <span class="number">27</span> - <span class="number">37</span>*x ^ <span class="number">26</span> + <span class="number">926</span>*x ^ <span class="number">25</span> - <span class="number">602</span>*x ^ <span class="number">24</span> - <span class="number">442</span>*x ^ <span class="number">23</span> - <span class="number">523</span>*x ^ <span class="number">22</span> - <span class="number">260</span>*x ^ <span class="number">21</span> + <span class="number">530</span>*x ^ <span class="number">20</span> - <span class="number">796</span>*x ^ <span class="number">19</span> + <span class="number">443</span>*x ^ <span class="number">18</span> + <span class="number">902</span>*x ^ <span class="number">17</span> - <span class="number">210</span>*x ^ <span class="number">16</span> + <span class="number">926</span>*x ^ <span class="number">15</span> + <span class="number">785</span>*x ^ <span class="number">14</span> + <span class="number">440</span>*x ^ <span class="number">13</span> - <span class="number">572</span>*x ^ <span class="number">12</span> - <span class="number">268</span>*x ^ <span class="number">11</span> - <span class="number">217</span>*x ^ <span class="number">10</span> + <span class="number">26</span>*x ^ <span class="number">9</span> + <span class="number">866</span>*x ^ <span class="number">8</span> + <span class="number">19</span>*x ^ <span class="number">7</span> + <span class="number">778</span>*x ^ <span class="number">6</span> + <span class="number">923</span>*x ^ <span class="number">5</span> - <span class="number">197</span> * x ^ <span class="number">4</span> - <span class="number">446</span>*x ^ <span class="number">3</span> - <span class="number">202</span>*x ^ <span class="number">2</span> - <span class="number">353</span>*x - <span class="number">852</span></span><br><span class="line"></span><br><span class="line">pub_key_coeffs = pub_key.coefficients()</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">mul</span><span class="params">(f, g)</span>:</span></span><br><span class="line">    <span class="keyword">return</span> (f * g) % (x ^ n<span class="number">-1</span>)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">bal_mod</span><span class="params">(f, q)</span>:</span></span><br><span class="line">    g = list(((f[i] + q//<span class="number">2</span>) % q) - q//<span class="number">2</span> <span class="keyword">for</span> i <span class="keyword">in</span> range(n))</span><br><span class="line">    <span class="keyword">return</span> Zx(g)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">inv_mod_prime</span><span class="params">(f, p)</span>:</span></span><br><span class="line">    T = Zx.change_ring(Integers(p)).quotient(x ^ n<span class="number">-1</span>)</span><br><span class="line">    <span class="keyword">return</span> Zx(lift(<span class="number">1</span> / T(f)))</span><br><span class="line"></span><br><span class="line">M_h = Matrix(n*<span class="number">2</span>, n*<span class="number">2</span>, <span class="number">0</span>)</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> range(n):</span><br><span class="line">    M_h[i, i], M_h[n+i, n+i] = <span class="number">1</span>, q</span><br><span class="line">    <span class="keyword">for</span> j <span class="keyword">in</span> range(n):</span><br><span class="line">        M_h[i, n+j] = pub_key_coeffs[j]</span><br><span class="line">    pub_key_coeffs.insert(<span class="number">0</span>, pub_key_coeffs.pop())</span><br><span class="line"></span><br><span class="line">M_r = M_h.BKZ(block_size=<span class="number">24</span>)</span><br><span class="line">t = [i <span class="keyword">for</span> i <span class="keyword">in</span> M_r[<span class="number">0</span>]]</span><br><span class="line">f, g = Zx(t[:n]), Zx(t[n:])</span><br><span class="line">fp = inv_mod_prime(f, p)</span><br><span class="line">a = bal_mod(mul(f, e), q)</span><br><span class="line">m = bal_mod(mul(fp, a), p)</span><br><span class="line"><span class="keyword">for</span> k <span class="keyword">in</span> range(<span class="number">8</span>):</span><br><span class="line">    flag = k*<span class="string">"0"</span>+<span class="string">""</span>.join([str(i) <span class="keyword">for</span> i <span class="keyword">in</span> m.list()])</span><br><span class="line">    flag += (<span class="number">8</span>-len(flag) % <span class="number">8</span>)*<span class="string">"0"</span></span><br><span class="line">    temp = <span class="string">""</span></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(len(flag)//<span class="number">8</span>):</span><br><span class="line">        temp += chr(int(flag[i*<span class="number">8</span>:i*<span class="number">8</span>+<span class="number">8</span>], <span class="number">2</span>))</span><br><span class="line">    print(temp)</span><br></pre></td></tr></table></figure>

<h2 id="flag-5"><a href="#flag-5" class="headerlink" title="flag"></a>flag</h2><p>@#26f35b89d3#@</p>

    </div>

    
    
    
        <div class="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/file/weixin.png" alt="粗制乱造 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/file/zfb.png" alt="粗制乱造 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/CTF/" rel="tag"># CTF</a>
              <a href="/tags/%E7%BB%83%E4%B9%A0%E9%A2%98/" rel="tag"># 练习题</a>
              <a href="/tags/%E5%AF%86%E7%A0%81%E5%AD%A6/" rel="tag"># 密码学</a>
              <a href="/tags/RSA/" rel="tag"># RSA</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/ctf_web_buuoj_cn_BJDCTF_2nd_duangShell1/" rel="prev" title="【BJDCTF 2nd】duangShell">
      <i class="fa fa-chevron-left"></i> 【BJDCTF 2nd】duangShell
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/ctf_web_buuoj_cn_HITCON_2017_SSRF_Me_17/" rel="next" title="【HITCON 2017】SSRFMe">
      【HITCON 2017】SSRFMe <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#0x01-can-you-get-the-equation"><span class="nav-number">1.</span> <span class="nav-text">0x01. can you get the equation</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#题目"><span class="nav-number">1.1.</span> <span class="nav-text">题目</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解题原理"><span class="nav-number">1.2.</span> <span class="nav-text">解题原理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解题代码"><span class="nav-number">1.3.</span> <span class="nav-text">解题代码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#flag"><span class="nav-number">1.4.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#0x02-rsa-roar-babyrsa"><span class="nav-number">2.</span> <span class="nav-text">0x02. rsa roar babyrsa</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#题目源码"><span class="nav-number">2.1.</span> <span class="nav-text">题目源码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解题原理-1"><span class="nav-number">2.2.</span> <span class="nav-text">解题原理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解题代码-1"><span class="nav-number">2.3.</span> <span class="nav-text">解题代码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#flag-1"><span class="nav-number">2.4.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#0x03-rsa-roar-rsa1"><span class="nav-number">3.</span> <span class="nav-text">0x03. rsa roar rsa1</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#题目源码-1"><span class="nav-number">3.1.</span> <span class="nav-text">题目源码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解题原理-2"><span class="nav-number">3.2.</span> <span class="nav-text">解题原理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解题代码-2"><span class="nav-number">3.3.</span> <span class="nav-text">解题代码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#flag-2"><span class="nav-number">3.4.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#0x04-common-rsa"><span class="nav-number">4.</span> <span class="nav-text">0x04. common rsa</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#解题"><span class="nav-number">4.1.</span> <span class="nav-text">解题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#flag-3"><span class="nav-number">4.2.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#0x05-lattice-based-attack-on-common-private-Exponent-RSA"><span class="nav-number">5.</span> <span class="nav-text">0x05. lattice_based_attack_on_common_private_Exponent_RSA</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#原题"><span class="nav-number">5.1.</span> <span class="nav-text">原题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解题-1"><span class="nav-number">5.2.</span> <span class="nav-text">解题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#flag-4"><span class="nav-number">5.3.</span> <span class="nav-text">flag</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#0x06-NTRU-Encrypt-Lattice-attack"><span class="nav-number">6.</span> <span class="nav-text">0x06. NTRU_Encrypt_Lattice_attack</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#原题-1"><span class="nav-number">6.1.</span> <span class="nav-text">原题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解题-2"><span class="nav-number">6.2.</span> <span class="nav-text">解题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#flag-5"><span class="nav-number">6.3.</span> <span class="nav-text">flag</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="粗制乱造"
      src="/file/avatar.png">
  <p class="site-author-name" itemprop="name">粗制乱造</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">43</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">59</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">粗制乱造</span>
</div>
  <div class="powered-by">由 <a href="https://czlz.net/" class="theme-link">czlz.net</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

</body>
</html>
